{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form layui-form-pane" lay-filter="form">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 150px">网关编号</label>
            <div class="layui-input-4">
                <input type="text" name="gateway_id" lay-verify="required" placeholder="请输入网关编号" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 150px">网关名称</label>
            <div class="layui-input-4">
                <input type="text" name="gateway_name" lay-verify="required" placeholder="请输入网关名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 150px">选择大棚</label>
            <div class="layui-input-4">
                <select name="house_id">
                    <option value="">选择大棚</option>
                    {volist  name='house' id='vo'}
                    <option value="{$vo.id}">{$vo.house_name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                <a onclick="navigate_back()" class="layui-btn layui-btn-primary">{:lang('back')}</a>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form, layer = layui.layer,$= layui.jquery;
        form.on('submit(submit)', function (data) {
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post('{:url("addGateway")}', data.field, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
//                        location.href = res.url;
                        window.parent.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        });
    });
    function navigate_back() {
        //parent.location.href="index";
        parent.layer.closeAll();
    }
</script>